
import torch
import random
import torch.utils.data as data
import h5py
import utils.utils as utils
from .database import Database
class  AkkoandKayo(Database):
    def __init__(self,cfg,flag='train'):
        self.img_size = cfg.img_size
        self.height = 480
        self.width = 640 
        self.Znear=2342.2485325395
        self.Zfar=12491.9921735441
        self.framnumber=298
        self.traincames=[28,48]
        self.testcames=[68]
        self.cames=[28,48,68]
        # # if utils.ip=='175':
        # #      self.h5path='/data2/kaixindata/h5data/Akko/Akko{}.h5'
        # # if utils.ip=='176':
        # #      self.h5path='/data1/kaixindata/h5data/Akko/Akko{}.h5'
        self.h5path = cfg.data_root
        # self.h5path=cfg.data_root
        self.flag=flag
        super(AkkoandKayo, self).__init__(flag)
    def getdata(self,cames,fram):
        cams1='cam{}'.format(cames)
        with h5py.File(self.h5path.format(cames),'r') as f:
            mask=torch.from_numpy(f[cams1]['mask'][fram]/255).unsqueeze(0)
            pictureL=torch.from_numpy(f[cams1]['imgL'][fram]/255).permute(2,0,1)  #名称为image 
            pictureR =torch.from_numpy(f[cams1]['imgR'][fram]/255).permute(2,0,1) #名称为image
            dpointL =torch.from_numpy(f[cams1]['Lerror'][fram]).permute(2,0,1)  #名称为image
            dpointR=torch.from_numpy(f[cams1]['Rerror'][fram]).permute(2,0,1)  #名称为image
            targets=torch.from_numpy(f[cams1]['target'][fram]/255).permute(2,0,1)   #名称为image
        return mask,pictureL,pictureR,dpointL,dpointR,targets